﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.IO;

namespace Circa.Configuration {

    public class Storage {

        public static Root Load( string fileName ) {
            return (Root) ( new XmlSerializer( typeof( Root ) ).Deserialize( File.OpenRead( fileName ) ) );
        }

        public static void Save( string fileName, Root conf ) {
            new XmlSerializer( typeof( Root ) ).Serialize( File.Create( fileName ), conf );
        }

    }

    public class Root {
        public List<Network> Networks;
    }

    public class Identity {
        public string Name;
        public string Description;

        public List<string> Nicks;
        public string UserName;
        public string HostName;
        public string RealName;
    }

    public class Network {
        public List<Identity> Identities;
        public List<Server> Servers;
        public List<Channel> Channels;
        public bool AutoConnect;
        public string Name;
        public string Description;
    }

    public class Channel {
        public string Name;
        public string Description;
        public string Key;
        public bool AutoJoin;
    }

    public class Server {
        public string Name;
        public string Description;

        public List<string> HostNames;
        public List<ushort> Ports;
        public string Password;
        public List<Channel> Channels;
    }

    public class SslServer: Server {
        public List<ushort> SslPorts;
    }

}
